package net.app.zoneland.platform.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import net.app.zoneland.domain.SysRoleMenu;
import net.app.zoneland.dto.MenuDTO;
import org.apache.ibatis.annotations.Select;
import org.mapstruct.Mapper;
import java.util.List;

/**
 * @Description
 * @Author LENOVO
 * @CreateTime 2020/12/26 12:52
 * @Version: 1.0
 */
@Mapper
public interface SysRoleMenuMapper extends BaseMapper<SysRoleMenu> {

    /**
     * 根据菜单ID查询角色
     * @param menuId
     * @return
     */
    @Select("<script>" +
            "  select role_id from sys_role_menu where menu_id=#{menuId} " +
            "</script>")
    List<Integer> listByMenuId(Integer menuId);

    @Select("<script>" +
            "  select r.menu_id menuId, m.`name` from sys_role_menu r join sys_menu m where r.role_id=#{roleId} and r.menu_id=m.id" +
            "</script>")
    List<MenuDTO> findByRoleId(Integer roleId);

    void insertAuthBatch(List<SysRoleMenu> list);
}
